/********************************************************************
	Rhapsody	: 7.5 
	Login		: KBE
	Component	: DefaultComponent 
	Configuration 	: CodeConfig
	Model Element	: SimulatorReactorImplementation
//!	Generated Date	: Wed, 19, Sep 2012  
	File Path	: DefaultComponent\CodeConfig\SimulatorReactorImplementation.cpp
*********************************************************************/

//## auto_generated
#include "SimulatorReactorImplementation.h"
//## link itsStubSynchronousEventDemultiplexer
#include "StubSynchronousEventDemultiplexer.h"
//## dependency SocketReactorImplementation
#include "SocketReactorImplementation.h"
//## package Default

//## class SimulatorReactorImplementation
SimulatorReactorImplementation::~SimulatorReactorImplementation() {
    cleanUpRelations();
}

void SimulatorReactorImplementation::handleEvents(int time) {
    //#[ operation handleEvents(int)
    
    Event_Type eventType = READ_EVENT; 
    HANDLE h;
    
    // Prototype test for simulating 4 events
    for (int i = 0; i < 4; i++)
    {   
    	
    	h = itsStubSynchronousEventDemultiplexer->SimulateEvents(); 
        	    
        printf("handler %d\n", h);
        EventHandler *eh = getItsEventHandler(h);
        if (eh != NULL)
        	eh->handleEvent(h, eventType);
        	 	      
    };
    //#]
}

StubSynchronousEventDemultiplexer* SimulatorReactorImplementation::getItsStubSynchronousEventDemultiplexer() const {
    return itsStubSynchronousEventDemultiplexer;
}

void SimulatorReactorImplementation::cleanUpRelations() {
    if(itsStubSynchronousEventDemultiplexer != NULL)
        {
            itsStubSynchronousEventDemultiplexer = NULL;
        }
}

SimulatorReactorImplementation::SimulatorReactorImplementation() {
    itsStubSynchronousEventDemultiplexer = NULL;
    //#[ operation SimulatorReactorImplementation()
    itsStubSynchronousEventDemultiplexer = new StubSynchronousEventDemultiplexer();
    //#]
}

/*********************************************************************
	File Path	: DefaultComponent\CodeConfig\SimulatorReactorImplementation.cpp
*********************************************************************/
